import Taro, { Component } from '@tarojs/taro'
import { View, Picker } from '@tarojs/components'


import './cityOption.less'


class CityOption extends Component {
    componentWillReceiveProps(nextProps) {
        console.log(this.props, nextProps)
    }
    componentWillMount() {
        Taro.getLocation({
            type: 'wgs84', //返回可以用于wx.openLocation的经纬度
            success() {
                // const latitude = res.latitude
                // const longitude = res.longitude
                //   Taro.openLocation({
                //     latitude,
                //     longitude,
                //     scale: 20
                //   })
            }
        })
        Taro.chooseLocation({
            success(ress){
                console.log(ress)
            },
            fail: function(err) {
                console.log(err)
            }
          })
    }
    state = {
        dateSel: '2018:22'
    }
    componentWillUnmount() { }

    componentDidShow() { }

    componentDidHide() { }
    onDateChange(v) {
        this.setState({
            dateSel: v.detail.value[2]
        })
        console.log(v.detail.value)
    }

    render() {
        return (
            <View className='comp-city'>
                <Picker mode='region' onChange={this.onDateChange.bind(this)}>
                    <View className='picker'>
                        当前选择：{this.state.dateSel}
                    </View>
                </Picker>
            </View>
        )
    }
}

export default CityOption
